// Functions associated with the MainMenu class
//-----------------

//-----------------
// Includes libraries and other files
#include "MainMenu.h"
//-----------------

//-----------------
//// CONSTRUCTOR - MainMenu
MainMenu::MainMenu() {}

//// DESTRUCTOR - ~MainMenu
MainMenu::~MainMenu() {}
//-----------------

//-----------------
//// FUNCTION - set_text
// set the buttons that will be used
void MainMenu::set_text( UserInterface* p_ui, int w, int h) {
	// Pre-conditions :- the width and height of the window must be positive and the interface pointer must exist
	assert( w >= 0 && h >= 0 && p_ui != nullptr);

	int y( 0);

	// set the y position to the middle of the screen (unless doing so would cause the bottom buttons to be rendered off screen
	if( h/2 < 240)
		y = h - 240;
	else
		y = h/2;

	// set the text's position, alpha channel and RGB colour
	create_button( "New Game",			70, y     , 255, 255, 255, 255);
	create_button( "Instructions",		70, y+  30, 255, 255, 255, 255);
	create_button( "Options",			70, y+  60, 255, 255, 255, 255);
	create_button( "Create Module",		70, y+  90, 255, 255, 255, 255);
	create_button( "Quit",				70, y+ 120, 255, 255, 255, 255);

	// give the menu a pointer to the UserInterface
	set_information( p_ui);
}

//// FUNCTION - setup_geometry
// create the objects that will be used
HRESULT MainMenu::setup_geometry( LPDIRECT3DDEVICE9& device) {
	// Pre-conditions :- the device must exist
	assert( device != NULL);

	HRESULT hr;
	
	hr = bg.setup( device);
	hr = hr | D3DXCreateTextureFromFile( device, (PATH_ORTHOGRAPHIC+"texture_opening_screen_background.bmp").c_str(), &bg_texture);

	return hr;
}